package com.voda.mail.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.stereotype.Component;

/**
 * The Class EmailSender.
 */
@Component
public class EmailSender {
	
	/** The email sender. */
	@Autowired
    private JavaMailSenderImpl emailSender;
	
    /**
     * Sets the email sender config.
     *
     * @param email the email
     * @param password the password
     */
    private void setEmailSenderConfig(String email, String password){
        emailSender.setUsername(email);
        emailSender.setPassword(password);
    }
    
    /**
     * Gets the email sender.
     *
     * @param email the email
     * @param password the password
     * @return the email sender
     */
    public JavaMailSenderImpl getEmailSender(String email, String password) {
    	setEmailSenderConfig(email, password);
    	return emailSender;
    }

}
